import static java.lang.Math.sqrt;

public class shiyan2_4 {
    double realpart,imagepart;
    public shiyan2_4(double R,double I){
        realpart=R;
        imagepart=I;
    }
    public double getRealPart(){
        return realpart;
    }
    public double getImagePart(){
        return imagepart;
    }
    public shiyan2_4 Complexjiafa(shiyan2_4 a){
        return new shiyan2_4((realpart+a.realpart),imagepart+a.imagepart);
    }
    public shiyan2_4 Complexjianfa(shiyan2_4 a){
        return new shiyan2_4((realpart-a.realpart),imagepart-a.imagepart);
    }
    public shiyan2_4 Complexchengfa(shiyan2_4 a){
        return new shiyan2_4((realpart*a.realpart-imagepart*a.imagepart),realpart*a.imagepart+imagepart*a.realpart);
    }
    public shiyan2_4 Complexchufa(shiyan2_4 a){
        double d = sqrt(a.realpart*a.realpart)+sqrt(a.imagepart*a.imagepart);
        double e = (realpart*a.imagepart-imagepart*a.realpart);
        return new shiyan2_4((realpart*a.realpart+imagepart*a.imagepart)/d,imagepart/a.imagepart);
    }
    public static void main(String args[]){
        shiyan2_4 w = new shiyan2_4(2,10);
        shiyan2_4 e = new shiyan2_4(1,3);
        shiyan2_4 a = new shiyan2_4(4,5);
        shiyan2_4 b = new shiyan2_4(3,7);
        a.Complexjiafa(b);
        System.out.println("("+a.realpart+"+"+a.imagepart+"i)+("+b.realpart+"+"+b.imagepart+"i)="+a.Complexjiafa(b).realpart+"+"+a.Complexjiafa(b).imagepart+"i");
        System.out.println("("+a.realpart+"+"+a.imagepart+"i)-("+e.realpart+"+"+e.imagepart+"i)="+a.Complexjianfa(e).realpart+"+"+a.Complexjianfa(e).imagepart+"i");
        System.out.println("("+a.realpart+"+"+a.imagepart+"i)*("+b.realpart+"+"+b.imagepart+"i)="+a.Complexchengfa(b).realpart+"+"+a.Complexchengfa(b).imagepart+"i");
        System.out.println("("+a.realpart+"+"+a.imagepart+"i)/("+w.realpart+"+"+w.imagepart+"i)="+a.Complexchufa(w).realpart+"+"+a.Complexchufa(w).imagepart+"i");
    }

}